package org.lvgo.factory.kit;

import java.util.function.Consumer;

/**
 * 接受单个输入参数并且不返回结果的操作。
 * 与大多数其他功能接口不同， Consumer预期通过副作用进行操作。
 *
 * @since 1.8
 *
 * @author lvgo
 */
public class FactoryKit {

    public static void main(String[] args) {
        Consumer<Builder> consumer = builder -> {
            builder.canBuild(WeaponType.AXE, Axe::new);
            builder.canBuild(WeaponType.BOW, Bow::new);
            builder.canBuild(WeaponType.SPEAR, Spear::new);
            builder.canBuild(WeaponType.SWORD, Sword::new);
        };
        WeaponFactory w = WeaponFactory.getFactory(consumer);
        Weapon weapon = w.create(WeaponType.BOW);
        System.out.println("weapon = " + weapon);
    }
}
